<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/7/13
 * Time: 10:22
 * Project name: PHPTEST
 * File name: 1.php
 * @copyright Copyright (c) 2016 ZRX Software LLC
 * @license https://github.com/zhangrxiang
 * @since 1.0.0
 */

$arr = range( 1, 10 );
shuffle( $arr );
foreach ( $arr as $values ) {
	echo $values . " ";
}

function rand_digital( $length ) {
	$digital = '';
	$arr = range( 1, 9 );
	shuffle( $arr );
	for ($i = 0; $i < $length; $i++){
		$digital .=$arr[$i];
	}
	return $digital;
}

echo rand_digital(4);